package com.xique.api.controller;

import com.xique.api.api.model.LoginApiThirdToken;
import com.xique.api.bean.request.ThirdAccountAddRequest;
import com.xique.api.service.biz.service.IApiThirdTokenBizService;
import com.xique.common.core.domain.R;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author shd
 * @create 2022/2/23 20:12
 */

@RestController
@RequestMapping("/accessToken")
public class AccessTokenController extends BaseController {

    @Autowired
    private IApiThirdTokenBizService apiThirdTokenBizService;

    @GetMapping("/getThirdAccount")
    public R<LoginApiThirdToken> getThirdAccount(String appId, String appSecret) {
        return apiThirdTokenBizService.getThirdAccount(appId, appSecret);
    }

    @GetMapping("/getAppInfo")
    public AjaxResult getAppIdAndAppSecret() {
        return apiThirdTokenBizService.getAppIdAndAppSecret();
    }

    @PostMapping("add")
    public AjaxResult add(@RequestBody @Valid ThirdAccountAddRequest request) {
        return apiThirdTokenBizService.addThirdAccount(request);
    }
}
